package com.kaka.bus;

import android.content.Context;

import com.bqs.risk.df.android.BqsDF;
import com.bqs.risk.df.android.BqsParams;
import com.bqs.risk.df.android.OnBqsDFCallRecordListener;
import com.kaka.bus.constant.Constant;
import com.kaka.bus.util.logger.Logger;

/**
 * Created by OnionMac on 2018/5/24.
 */

public class BaiQiShi {

    public static final String BQS_TOKENKEY = "bqs_tokenkey";

    public static void initBaiQiShi(Context context){

        if(BqsDF.getInstance().canInitBqsSDK()){
            Logger.i("初始化白骑士开始");
            BqsDF.getInstance().setOnBqsDFListener(new OnBqsDFCallRecordListener() {

                @Override
                public void onGatherResult(boolean b) {

                }

                @Override
                public void onSuccess(String tokenKey) {
                    Logger.i("初始化白骑士的tokenKey,回调的"+tokenKey);
                    AppCenter.mSpUtil.putString(BQS_TOKENKEY,tokenKey);
                }

                @Override
                public void onFailure(String s, String s1) {
                    Logger.i("上传tokenKey信息失败了"+s+s1);
                    AppCenter.mSpUtil.putString(BQS_TOKENKEY,BqsDF.getInstance().getTokenKey());
                }
            });

            BqsParams params = new BqsParams();
            params.setTestingEnv(false);//是否开发环境
            params.setGatherGps(true);//是否忽略 GPS 定位
            params.setPartnerId(Constant.APP_PARTNERID);//商户合作编号
            BqsDF.getInstance().initialize(context,params);
            String tokenKey = BqsDF.getInstance().getTokenKey();

            Logger.i("初始化白骑士的tokenKey"+tokenKey);
            AppCenter.mSpUtil.putString(BQS_TOKENKEY,tokenKey);
        }
    }

}
